﻿CREATE proc [dbo].[proc_Customer_Track_CategoryList]
(
	@departmentid int
)
as
	select 
		 customerid,
		ct.id,
		(select c.customername from customer c where c.customerid=ct.customerid) as customername,
		Intentionsid,
		(select phases from Customer_Intentions ci where ci.id=ct.IntentionsId) as IntentionsPhases,
		(select title from Customer_Intentions ci where ci.id=ct.IntentionsId) as IntentionsTitle,
		(select cp.phases from Customer_PublicityDemand cp where cp.id=ct.PublicityDemandId) as PublicityDemandPhases,
		(select cp.Title from Customer_PublicityDemand cp where cp.id=ct.PublicityDemandId) as PublicityDemandTitle,
		(select cn.id from Customer_NetworkConsciousness cn where cn.id=ct.NetworkConsciousnessId) as NetworkConsciousnessId,
		(select cn.title from Customer_NetworkConsciousness cn where cn.id=ct.NetworkConsciousnessId) as NetworkConsciousnessTitle,
		genjinid,
		(select title from customer_genjin cg where cg.id=ct.genjinid) as genjin,
		record,
		uptime
        from 
		Customer_Track ct
	where
		    ct.departmentid=@departmentid
		and ct.PublicityDemandId <>0 and NetworkConsciousnessId<>0
